package com.trt.eatmeat.test;

import cn.hutool.json.JSONUtil;

public  class Solution4 {
    public int trap(int[] nums) {
        int length= nums.length;
        for(int i=0;i<length-1;i++){
            // 有重复，则全部后面移位
            while (nums[i]==nums[i+1] && length>1 && i+1<length){
                for (int  j=i+1;j<length-1;j++){
                    nums[j]=nums[j+1];
                }
                //System.out.println(JSONUtil.toJsonStr(nums));
                length--;
            }
        }
        return length;
    }

    public String replaceSpace(String s) {
        String r="";
        for(int i=0;i<s.length();i++){
            char temp = s.charAt(i);
            if(temp==' '){
                r+="%20";
            }else{
                r+=temp;
            }
        }
        return r;
    }

    public static void main(String[] args) {
        Solution4 solution = new Solution4();
       int flag = solution.trap(new int[]{1,2,2});
       System.out.println(flag);
    }
}